import thinkingdata from "thinkingdata-browser";

const GlobalMixins = {
  data () {
    // let query = this.$route && this.$route.query ? this.$route.query : {}
    return {
      // 沉浸式页面设置高度
      // barHeight: query.bar_height || client.pageTopHeight()
    };
  },
  computed: {
    env () {
      const ua = navigator.userAgent;
      let env = {
        ua: ua,
        isApp: /\/dq\//i.test(ua),
        isMobile: /android|iphone|ipod|ipad/i.test(ua),
        isIOS: /iphone|ipod|ipad|ios|mac os/i.test(ua),
        isAndroid: /android/i.test(ua),
        isWechat: /micromessenger/i.test(ua),
        isQQ: /qq\//i.test(ua),
        isWeibo: /weibo/i.test(ua),
        isDingTalk: /dingtalk/i.test(ua)
      };
      env.isBrowser = !(
        env.isApp ||
        env.isWechat ||
        env.isQQ ||
        env.isWeibo ||
        env.isDingTalk
      );
      return env;
    },
  },
  created () {
    this.thinkingInit()
  },
  destroyed () {
  },
  methods: {
    // 跳转页面
    toPath (path) {
      this.$router.push(path)
    },

    // 数数
    thinkingInit () {
      var config = {
        appId: '93ac254b2b0743b992582b519dc18863',
        serverUrl: "https://log.lnk.events/",
      };
      window.ta = thinkingdata;
      //初始化SDK
      ta.init(config);
    },
  }
};
export default GlobalMixins;
